package com.example.demo.RedisTest.UsageCollection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Redis使用方法合集
 *
 * @author FF998
 */
@RestController
@RequestMapping("/RedisUsage")
public class RedisUsageController {

    @Autowired
    RedisUsageService redisUsageService;

    /**
     * 抽奖-添加用户
     */
    @PostMapping("/RaffleAddUser")
    public Boolean raffleAddUser(@RequestBody List<String> userList) {
        return redisUsageService.raffleAddUser(userList);
    }

    /**
     * 抽奖-获取用户
     */
    @GetMapping("/RaffleGetUser/{num}")
    public String raffleGetUser(@PathVariable(value = "num") long num) {
        return redisUsageService.raffleGetUser(num);
    }

    /**
     * 抽奖-获取并删除用户
     */
    @GetMapping("/RaffleGetDeleteUser/{num}")
    public String raffleGetDeleteUser(@PathVariable(value = "num") long num) {
        return redisUsageService.raffleGetDeleteUser(num);
    }

    /**
     * 排行榜-随机添加数据
     */
    @GetMapping("/RankingAddData")
    public Boolean rankingAddData(){
        return redisUsageService.rankingAddData();
    }

    /**
     * 排行榜-排序
     */
    @GetMapping("/RankingSort/{type}/{num}")
    public List rankingSort(@PathVariable(value = "type") String type,@PathVariable(value = "num") long num){
        return redisUsageService.rankingSort(type,num);
    }

}
